package org.updateNew;

import java.io.BufferedReader;
import java.io.CharArrayWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import org.apache.commons.io.IOUtils;

import com.tool.btn.LineReplaceEntity;

public class updateTcp {
	

	static String ur = System.getProperty("user.dir");
	static String path = ur+"/skin/500173/dslmy/10995116297761/stand1.tcp";
//	static String path="K:/Test/Name.txt";//路径
    public static void main(String[] args) {
        File fileText=new File(path);//文件
        if(fileText.canExecute()) //如果文件存在就继续
        {
            setText(fileText,"SP","SP");//“刚”指定改为：“XX”
        }
    }
    private static void setText(File fileText,String target,String src) {//修改
        BufferedReader br=null;
        PrintWriter pw=null;
        StringBuffer buff=new StringBuffer();//临时容器!
        
        String line=System.getProperty("line.separator");//平台换行!
        try {
            br=new BufferedReader(new FileReader(fileText));
            for(String str=br.readLine();str!=null;str=br.readLine()) {
                if(str.contains(target)) {
                    str=str.replaceAll(target,src);
                }
                buff.append(str+line);
            }
            pw=new PrintWriter(new FileWriter(fileText),true);
            pw.println(buff);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(br!=null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if(pw!=null) {
                pw.close();
            }
        }
    }
}
